package com.pandora.credit.mongo.dao.impl;

import com.pandora.credit.mongo.dao.MongoAnnouncementDao;
import com.pandora.credit.mongo.entity.MongoAnnouncement;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.data.mongodb.core.query.Query;
import org.springframework.stereotype.Repository;

import javax.annotation.Resource;

/**
 * @author developer
 */
@Repository("mongoAnnouncementDaoImpl")
public class MongoAnnouncementDaoImpl implements MongoAnnouncementDao {
    @Resource
    private MongoTemplate mongoTemplatePc;

    @Override
    public MongoAnnouncement selectById(long id) {
        Query query = new Query();
        Criteria criteria = Criteria.where("_id").is(id);
        query.addCriteria(criteria);
        MongoAnnouncement mongoAnnouncement = mongoTemplatePc.findOne(query, MongoAnnouncement.class);
        return mongoAnnouncement;
    }
}
